Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the templating engine and the command tool cache et al. #615

Merged
merged 5 commits into from
Oct 15, 2020
Merged

Refactor the templating engine and the command tool cache et al. #615

merged 5 commits into from
Oct 15, 2020

Conversation

teo-tsirpanis
Copy link
Contributor

@teo-tsirpanis teo-tsirpanis commented Oct 14, 2020

This PR:

  • Fixes The command tool's cache is serialized with the BinaryFormatter #614 by serializing the command tool's cache with the safer DataContractSerializer instead of the insecure BinaryFormatter. The XML output of the serializer is encoded in binary to reduce its size.
  • Rewrites the template engine in Templating.fs to use a more efficient Span-based single-pass algorithm.
  • Optimizes the functions in the command tool's Options.fs, making them allocate less.
  • Removes some unused source files and ignores built-time assets generated by FAKE, like AssemblyInfo.?s and version.props, the latter of which being now generated with LINQ-to-XML.
  • The rest of the changes will be described in code review comments.

As a consequence of the templating engine rewrite, the FSharp.Formatting.Common package multi-targets to .NET Standard 2.1 in addition to 2.0, to take advantage of the StringBuilder.Append overload that takes a ReadOnlySpan (in .NET Standard 2.0 the span's content will be first copied to a string). The command tool will automatically use the .NET Standard 2.1 version.

However, the other public packages -namely FSharp.Formatting and FSharp.Formatting.Literate- still target only .NET Standard 2.0 because of concerns about the packages' size being doubled. Should I multi-target them as well?

Use an allocation-free implementation of the ParamKey type.
Fix formatting in BuildCommand.fs and syntax highlighting in _template.html.
It uses spans. For the most of allocation savings, FSharp.Formatting.Common now targets .NET Standard 2.1 too but the package is not yet updated; only the command tool will take advantage of all improvements.
Remove an unused source file.
And use LINQ-to-XML to generate version.props.
The cache is both more secure and more compact (the cache's size for this project was reduced by a third, after using binary XML).
And use a more reliable way to install the command tools during documentation generation.
build.fsx Show resolved Hide resolved
docs/_template.html Show resolved Hide resolved
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0; netstandard2.1</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why both?

/// An abbreviation for 'string' representing a strong name for a parameter key
type ParamKey = string
#endif
with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "with" is not needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And will not compile in release mode??)

@dsyme
Copy link
Contributor

dsyme commented Oct 15, 2020

However, the other public packages -namely FSharp.Formatting and FSharp.Formatting.Literate- still target only .NET Standard 2.0 because of concerns about the packages' size being doubled. Should I multi-target them as well?

Yes just multi-target them, or move them all to .NET Standard 2.1 (probably ok?)

@dsyme
Copy link
Contributor

dsyme commented Oct 15, 2020

Thanks, this looks great. Just move everything to netstandard 2.1 I think?

@dsyme dsyme merged commit 60cb2cf into fsprojects:master Oct 15, 2020
@teo-tsirpanis teo-tsirpanis deleted the patch-1 branch October 15, 2020 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The command tool's cache is serialized with the BinaryFormatter
2 participants